//
//  DYLoadView.m
//  DYHospital
//
//  Created by 胡金东 on 16/3/23.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "DYLoadView.h"
#import "MBProgressHUD.h"
#import "BSMacros.h"
@interface DYLoadView ()

@end

@implementation DYLoadView

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


/**
 * 显示提示信息
 */
- (void)showHint:(NSString *)msg
{
    [self showHint:msg inCenter:NO];
}

/**
 * 显示提示信息
 */
- (void)showHint:(NSString *)msg inCenter:(BOOL)inCenter
{
    if (msg == nil || [msg stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0) {
        return;
    }
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[self mainWindow] animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.animationType = MBProgressHUDAnimationZoom;
    hud.tag = 102;
    hud.removeFromSuperViewOnHide = YES;
    hud.detailsLabelText = msg;
    hud.detailsLabelFont = [UIFont systemFontOfSize:14.0f];
    hud.margin = 10.0f;
    hud.yOffset = IS_IPHONE_5 ? 180 : 140;
    if (inCenter) {
        hud.yOffset = .0f;
    }
    [hud hide:YES afterDelay:1.0f];
}

- (UIWindow *)mainWindow
{
    UIApplication *app = [UIApplication sharedApplication];
    if ([app.delegate respondsToSelector:@selector(window)])
    {
        return [app.delegate window];
    }
    else
    {
        return [app keyWindow];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
